﻿<!DOCTYPE HTML>
<html lang="zh">
<head>
<title>GuiControl 对象 - 方法 &amp; 属性 | AutoHotkey v2</title>
<meta name="description" content="The GuiControl object provides an interface for a GUI control to perform actions, such as moving, or to retrieve or set values, such as its text." />
<meta name="ahk:equiv-v1" content="commands/GuiControl.htm" />
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<link href="../static/theme.css" rel="stylesheet" type="text/css">
<script src="../static/content.js" type="text/javascript"></script>
<script type="text/javascript">$(function(){0<=window.navigator.userAgent.toLowerCase().indexOf("ucbrowser")&&CaoNiMaDeUc()})</script>
</head>
<body>

<h1>GuiControl 对象</h1>
<p>提供用于修改 GUI 控件并检索有关控件的信息的接口. <a href="Gui.htm#Add">Gui.Add</a>, <a href="Gui.htm#__Item">Gui.__Item</a> 和 <a href="../commands/GuiCtrlFromHwnd.htm">GuiCtrlFromHwnd</a> 返回这种类型的对象.</p>
<p><strong>属性:</strong></p>
<ul>
  <li><a href="#ClassNN">ClassNN</a>: 检索控件的 ClassNN.</li>
  <li><a href="#Enabled">Enabled</a>: 检索控件当前交互状态, 或启用或禁用(灰色) 控件.</li>
  <li><a href="#Focused">Focused</a>: 检索控件当前焦点状态.</li>
  <li><a href="#Gui">Gui</a>: 检索控件的 Gui 父控件.</li>
  <li><a href="#Hwnd">Hwnd</a>: 检索控件的 HWND.</li>
  <li><a href="#Name">Name</a>: 检索或设置控件的显式名称.</li>
  <li><a href="#Pos">Pos</a>: 控件的位置和大小.</li>
  <li><a href="#Text">Text</a>: 检索或设置控件的文本/标题.</li>
  <li><a href="#Type">Type</a>: 检索控件的类型.</li>
  <li><a href="#Value">Value</a>: Retrieves or sets new contents into a value-capable control.</li>
  <li><a href="#Visible">Visible</a>: 检索控件的当前可见状态, 或显示或隐藏它.</li>
</ul>
<p><strong>方法:</strong></p>
<ul>
  <li><a href="#Add">Add</a>: 在列表框, 下拉列表, 组合框或选项卡控件的当前列表中追加指定的项.</li>
  <li><a href="#Choose">Choose</a>: Sets the selection in a ListBox, DropDownList, ComboBox, or Tab control to be the specified value.</li>
  <li><a href="#Delete">Delete</a>: Deletes the specified entry or all entries of a ListBox, DropDownList, ComboBox, or Tab control.</li>
  <li><a href="#Focus">Focus</a>: Sets keyboard focus to the control.</li>
  <li><a href="#Move">Move</a>: Moves, resizes and/or redraws the control.</li>
  <li><a href="GuiOnEvent.htm">OnEvent</a>: Registers a function or method to be called when the given <a href="GuiOnEvent.htm#Control_Events">event</a> is raised.</li>
  <li><a href="GuiOnNotify.htm">OnNotify</a>: Registers a function or method to be called when a control notification is received via the <a href="https://msdn.microsoft.com/library/bb775583">WM_NOTIFY</a> message.</li>
  <li><a href="#Opt">Opt</a>: 为控件的外观和行为设置各种选项和样式.</li>
  <li><a href="#SetFont">SetFont</a>: 设置控件的字体字体, 大小, 样式和/或颜色.</li>
  <li><a href="../commands/GuiControls.htm#DateTimeFormat">SetFormat</a>: 设置 <a href="../commands/GuiControls.htm#DateTime">DateTime</a> 控件的显示格式.</li>
  <li><a href="#UseTab">UseTab</a>: 导致随后添加的控件属于选项卡控件的指定选项卡.</li>
</ul>

<div class="methodShort" id="Type">
<h2>Type</h2>
<p>Retrieves the type of the control.</p>
<pre class="Syntax">Type := GuiCtrl.Type</pre>
  <p>For a full list of control types, 请参阅 <a href="../commands/GuiControls.htm">GUI control types</a>.</p>
</div>

<div class="methodShort" id="Hwnd">
<h2>Hwnd</h2>
<p>Retrieves the window handle (HWND) of the control. </p>
<pre class="Syntax">Hwnd := GuiCtrl.Hwnd</pre>
<p>A control's HWND is often used with <a href="../commands/PostMessage.htm">PostMessage</a>, <a href="../commands/SendMessage.htm">SendMessage</a>, and <a href="../commands/DllCall.htm">DllCall</a>.</p>
</div>

<div class="methodShort" id="Name">
<h2>Name</h2>
<p>Retrieves or sets the name of the control.</p>
<pre class="Syntax">RetrievedName := GuiCtrl.Name</pre>
<pre class="Syntax">GuiCtrl.Name := NewName</pre>
<p>The control's name can be used with <a href="Gui.htm#__Item">Gui.__Item</a> to retrieve the GuiControl object. For most input-capable controls, the name is also used by <a href="Gui.htm#Submit">Gui.Submit</a>.</p>
</div>

<div class="methodShort" id="ClassNN">
<h2>ClassNN</h2>
<p>Retrieves the ClassNN of the control.</p>
<pre class="Syntax">ClassNN := GuiCtrl.ClassNN</pre>
</div>

<div class="methodShort" id="Gui">
<h2>Gui</h2>
<p>Retrieves the <a href="Gui.htm">Gui object</a> of the control's parent GUI window.</p>
<pre class="Syntax">GuiObj := GuiCtrl.Gui</pre>
</div>

<div class="methodShort" id="Opt">
<h2>Opt</h2>
<p>Adds or removes various options and styles of the control.</p>
<pre class="Syntax">GuiCtrl.<span class="func">Opt</span>(Options)</pre>
<dl>
  <dt>Options</dt><dd>
    <p>类型: <a href="../Concepts.htm#strings">字符串</a></p>
    <p>Either  <a href="../commands/GuiControls.htm">control-specific</a> or <a href="Gui.htm#OtherOptions">general</a> options and styles.</p>
  </dd>
</dl>
<p>In the following example, the control is <a href="Gui.htm#Disabled">disabled</a> and its <a href="Gui.htm#Background">background</a> is restored to the system default:</p>
<pre>MyEdit.Opt("+Disabled -Background")</pre>
<p>In the next example, the OK button is made the new default button:</p>
<pre>OKButton.Opt("+Default")</pre>
<p>Although <a href="../misc/Styles.htm">styles</a> and extended styles are also recognized, some of them cannot be applied or removed after a control has been created. ErrorLevel is set to 0 if at least one of the specified changes was successfully applied. Otherwise, it is set to 1 to indicate that none of the changes could be applied. Even if a change is successfully applied, the control might choose to ignore it.</p>
</div>

<div class="methodShort" id="Move">
<h2>Move</h2>
<p>Moves, resizes and/or redraws the control.</p>
<pre class="Syntax">GuiCtrl.<span class="func">Move</span>(Pos <span class="optional">, Draw := false</span>)</pre>
<dl>
  <dt>Pos</dt><dd>
    <p>类型: <a href="../Concepts.htm#strings">字符串</a></p>
    <p>One or more of the following option letters (specify each number as decimal, not hexadecimal):</p>
  <p><strong>Xn</strong>: Specify for <strong>n</strong> the new x-coordinate relative to the GUI window's client area, which is the area not including title bar, menu bar, and borders.</p>
  <p><strong>Yn</strong>: Specify for <strong>n</strong> the new y-coordinate relative to the GUI window's client area (see above).</p>
  <p><strong>Wn</strong>: Specify for <strong>n</strong> the new width of the control.</p>
  <p><strong>Hn</strong>: Specify for <strong>n</strong> the new height of the control.</p></dd>
  <dt>Draw</dt><dd>
    <p>类型: <a href="../Concepts.htm#boolean">整数(布尔值)</a></p>
    <p>If this parameter is 1 (true), the region of the GUI window occupied by the control will be redrawn. Although this may cause an unwanted flickering effect when called repeatedly and rapidly, it solves display artifacts for certain control types such as <a href="../commands/GuiControls.htm#GroupBox">GroupBoxes</a>.</p>
  </dd>
</dl>
<h3>Examples</h3>
<pre>MyEdit.Move("x10 y20 w200 h100", true)
MyEdit.Move("x" VarX+10 " y" VarY+5 " w" VarW*2 " h" VarH*1.5)</pre>
</div>

<div class="methodShort" id="Focus">
<h2>Focus</h2>
<p>Sets keyboard focus to the control.</p>
<pre class="Syntax">GuiCtrl.<span class="func">Focus</span>()</pre>
<p>Note: To be effective, the window generally must not be minimized or hidden.</p>
</div>

<div class="methodShort" id="Choose">
<h2>Choose</h2>
<p>Sets the selection in a ListBox, DropDownList, ComboBox, or Tab control to be the specified value.</p>
<pre class="Syntax">GuiCtrl.<span class="func">Choose</span>(Value)</pre>
<dl>
  <dt>Value</dt><dd>
    <p>类型: <a href="../Concepts.htm#numbers">整数</a>或<a href="../Concepts.htm#strings">字符串</a></p>
    <p>This parameter should be 1 for the first entry, 2 for the second, etc.</p>
    <p>If <em>Value</em> is a string (even a numeric string), the entry whose leading part matches <em>Value</em> will be selected. The search is not case sensitive. 例如, if the control contains the item "UNIX Text", specifying the word unix (lowercase) would be enough to select it. For a <a href="../commands/GuiControls.htm#ListBoxMulti">multi-select ListBox</a>, all matching items are selected.</p>
    <p>If <em>Value</em> is zero or empty, the current selection is removed.</p></dd>
</dl>
<p>To select or deselect <u>all</u> items in a <a href="../commands/GuiControls.htm#ListBoxMulti">multi-select ListBox</a>, follow this example:</p>
<pre>Gui.Opt("+LastFound")  <em>; Avoids the need to specify WinTitle below.</em>
<a href="../commands/PostMessage.htm">PostMessage</a> 0x185, 1, -1, ListBox  <em>; Select all items. 0x185 is LB_SETSEL.</em>
<a href="../commands/PostMessage.htm">PostMessage</a> 0x185, 0, -1, ListBox  <em>; Deselect all items.</em>
ListBox.Choose(0)  <em>; Deselect all items.</em></pre>
<p>Unlike <a href="../commands/ControlChoose.htm">ControlChoose</a>, this method does not raise a <a href="GuiOnEvent.htm#Change">Change</a> or <a href="GuiOnEvent.htm#DoubleClick">DoubleClick</a> event.</p>
</div>

<div class="methodShort" id="UseTab">
<h2>UseTab</h2>
<p>Causes subsequently added controls to be belong to the specified tab of a Tab control.</p>
<pre class="Syntax">GuiCtrl.<span class="func">UseTab</span>(<span class="optional">Value, ExactMatch := false</span>)</pre>
<dl>
  <dt>Value</dt><dd>
    <p>类型: <a href="../Concepts.htm#numbers">整数</a>或<a href="../Concepts.htm#strings">字符串</a></p>
    <p>This parameter should be 1 for the first tab, 2 for the second, etc. If <em>Value</em> is not an integer, the tab whose leading part matches <em>Value</em> will be used. The search is not case sensitive. 例如, if a the control contains the tab "UNIX Text", specifying the word unix (lowercase) would be enough to use it. If <em>Value</em> is zero, a blank string or omitted, subsequently controls are added outside the Tab control.</p>
  </dd>
  <dt>ExactMatch</dt><dd>
    <p>类型: <a href="../Concepts.htm#boolean">整数(布尔值)</a></p>
    <p>If this parameter is true, <em>Value</em> has to be an exact match, but not case sensitive.</p>
  </dd>
</dl>
</div>

<div class="methodShort" id="Add">
<h2>Add</h2>
<p>Appends the specified entries at the current list of a ListBox, DropDownList, ComboBox, or Tab control.</p>
<pre class="Syntax">GuiCtrl.<span class="func">Add</span>(ArrayOrList)</pre>
<dl>
  <dt>ArrayOrList</dt><dd>
    <p>类型: <a href="../Concepts.htm#objects">数组</a>或<a href="../Concepts.htm#strings">字符串</a></p>
    <p>A pipe-delimited list of entries (e.g. <code>"Red|Green|Blue"</code>) or an array of entries (e.g. <code>["Red", "Green", "Blue"]</code>) to be appended at the end of the control's list. To replace (overwrite) the list instead, use <a href="#Delete">GuiCtrl.Delete</a> beforehand. When using pipes, one of the entries can be pre-selected by including two pipes after it (e.g. <code>"Red|Green||Blue"</code>), otherwise use <a href="#Choose">GuiCtrl.Choose</a>. The separator between text fields may be changed to something other than pipe. 例如, <code>Gui.Opt("+<a href="Gui.htm#Delimiter">Delimiter</a>`n")</code> would change it to linefeed and <code>Gui.Opt("+DelimiterTab")</code> would change it to tab (`t).</p>
  </dd>
</dl>
<p><strong>Related:</strong> <a href="../commands/ListView.htm#Add">ListView.Add</a>, <a href="../commands/TreeView.htm#Add">TreeView.Add</a></p>
</div>

<div class="methodShort" id="Delete">
<h2>Delete</h2>
<p>Deletes the specified entry or all entries of a ListBox, DropDownList, ComboBox, or Tab control.</p>
<pre class="Syntax">GuiCtrl.<span class="func">Delete</span>(<span class="optional">Value</span>)</pre>
<dl>
  <dt>Value</dt><dd>
    <p>类型: <a href="../Concepts.htm#numbers">整数</a></p>
    <p>This parameter should be 1 for the first entry, 2 for the second, etc. If omitted, all entries are deleted.</p>
  </dd>
</dl>
<p>For tab controls, you should note that a tab's sub-controls stay associated with their original tab number; that is, they are never associated with their tab's actual display-name. For this reason, renaming or removing a tab will not change the tab number to which the sub-controls belong. 例如, if there are three tabs "Red|Green|Blue" and the second tab is removed by means of <code>MyTab.Delete(2)</code>, the sub-controls originally associated with Green will now be associated with Blue. Because of this behavior, only tabs at the end should generally be removed. Tabs that are removed in this way can be added back later, at which time they will reclaim their original set of controls.</p>
<p><strong>Related:</strong> <a href="../commands/ListView.htm#Delete">ListView.Delete</a>, <a href="../commands/TreeView.htm#Delete">TreeView.Delete</a></p>
</div>

<div class="methodShort" id="Value">
<h2>Value</h2>
<p>Retrieves or sets the contents of a control.</p>
<pre class="Syntax">RetrievedValue := GuiCtrl.Value</pre>
<pre class="Syntax">GuiCtrl.Value := NewValue</pre>
  <p>Note: If the control is not value-capable, <em>RetrievedValue</em> will be blank and assigning <em>NewValue</em> will raise an error. Invalid values throw an exception.</p>
  <p>Following control types are value-capable:</p>

<h3>Picture</h3>
<p><em>RetrievedValue</em> is the picture's file name as it was originally specified when the <a href="../commands/GuiControls.htm#Picture">Picture</a> control was created. This name does not change even if a new picture file name is specified.</p>
<p><em>NewValue</em> is the filename (or <a href="../misc/ImageHandles.htm">handle</a>) of the new image to load (see <a href="../commands/GuiControls.htm#Picture">Picture</a> for supported file types). Zero or more of the following options may be specified immediately in front of the filename: <code>*wN</code> (width N), <code>*hN</code> (height N), and <code>*IconN</code> (icon group number N in a DLL or EXE file).  In the following example, the default icon from the second icon group is loaded with a width of 100 and an automatic height via "keep aspect ratio": <code>MyPic.Value := "*icon2 *w100 *h-1 C:\My Application.exe"</code>. Specify <code>*w0 *h0</code> to use the image's actual width and height. If <code>*w</code> and <code>*h</code> are omitted, the image will be scaled to fit the current size of the control. When loading from a multi-icon .ICO file, specifying a width and height also determines which icon to load. Note: Use only one space or tab between the final option and the filename itself; any other spaces and tabs are treated as part of the filename.</p>

<h3>Text</h3>
<p><em>RetrievedValue</em> is the text/caption of the <a href="../commands/GuiControls.htm#Text">Text</a> control.</p>
<p><em>NewValue</em> is the control's new text. Since the control will not expand automatically, use <code>GuiCtrl.<a href="#Move">Move</a>("w300")</code> if the control needs to be widened.</p>

<h3>Edit</h3>
<p><em>RetrievedValue</em> is the current content of the <a href="../commands/GuiControls.htm#Edit">Edit</a> control. For multi-line controls, any line breaks in the text will be represented as plain linefeeds (`n) rather than the traditional CR+LF (`r`n) used by non-GUI functions such as <a href="../commands/ControlGetText.htm">ControlGetText</a> and <a href="../commands/ControlSetText.htm">ControlSetText</a>.</p>
<p><em>NewValue</em> is the new content. For multi-line controls, Any linefeeds (`n) in <em>NewValue</em> that lack a preceding carriage return (`r) are automatically translated to CR+LF (`r`n) to make them display properly. However, this is usually not a concern because when using <code>Gui.Submit</code> or when retrieving this value this translation will be reversed automatically by replacing CR+LF with LF (`n).</p>
  <p>To retrieve or set the text without translating `n to or from `r`n, use <a href="#Text">GuiCtrl.Text</a>.</p>

<h3>Hotkey</h3>
<p><em>RetrievedValue</em> is the modifiers and key name if there is a hotkey in the <a href="../commands/GuiControls.htm#Hotkey">Hotkey</a> control; otherwise blank. Examples: <code>^!C</code>, <code>^Home</code>, <code>+^NumpadHome</code>.</p>
<p><em>NewValue</em> can be a set of modifiers with a key name, or blank to clear the control. Examples: <code>^!c</code>, <code>^Numpad1</code>, <code>+Home</code>. The only modifiers supported are ^ (<kbd>Control</kbd>), ! (<kbd>Alt</kbd>), and + (<kbd>Shift</kbd>). See the <a href="../KeyList.htm">key list</a> for available key names.</p>

<h3>Checkbox / Radio</h3>
<p><em>RetrievedValue</em> is 1 if the <a href="../commands/GuiControls.htm#Checkbox">Checkbox</a> or <a href="../commands/GuiControls.htm#Radio">Radio</a> control is checked, 0 if it is unchecked, or -1 if it has a gray checkmark.</p>
<p><em>NewValue</em> can be 0 to uncheck the button, 1 to check it, or -1 to give it a gray checkmark. For Radio buttons,  if one is being checked (turned on) and it is a member of a multi-radio group, the other radio buttons in its group will be automatically unchecked.</p>
  <p>To get or set control's text/caption instead, use <a href="#Text">GuiCtrl.Text</a>.</p>

<h3>DateTime / MonthCal</h3>
<p><em>RetrievedValue</em> is a date-time stamp in <a href="../commands/FileSetTime.htm#YYYYMMDD">YYYYMMDDHH24MISS</a> format currently selected in the <a href="../commands/GuiControls.htm#DateTime">DateTime</a> or <a href="../commands/GuiControls.htm#MonthCal">MonthCal</a> control.</p>
<p><em>NewValue</em> is a date-time stamp in <a href="../commands/FileSetTime.htm#YYYYMMDD">YYYYMMDDHH24MISS</a> format. Specify <code>A_Now</code> to use the current date and time (today). For DateTime controls, <em>NewValue</em> may be an empty string to cause the control to have no date/time selected (if it was created with <a href="../commands/GuiControls.htm#ChooseNone">that ability</a>). For MonthCal controls, a range may be specified if the control is <a href="../commands/GuiControls.htm#MonthCalMulti">multi-select</a>.</p>

<h3>UpDown / Slider / Progress</h3>
<p><em>RetrievedValue</em> is the current position of the <a href="../commands/GuiControls.htm#UpDown">UpDown</a>, <a href="../commands/GuiControls.htm#Slider">Slider</a> or <a href="../commands/GuiControls.htm#Progress">Progress</a> control.</p>
<p><em>NewValue</em> is the new position of the control, for example <code>MySlider.Value := 10</code>. To adjust the value by a relative amount, use the operators <code>+=</code>, <code>-=</code>, <code>++</code> or <code>--</code> instead of <code>:=</code>. If the new position would be outside the range of the control, the control is generally set to the nearest valid value.</p>

<h3>Tab / DropDownList / ComboBox / ListBox</h3>
<p><em>RetrievedValue</em> is the position of the currently selected item/tab in the <a href="../commands/GuiControls.htm#Tab">Tab</a>, <a href="../commands/GuiControls.htm#DropDownList">DropDownList</a>, <a href="../commands/GuiControls.htm#ComboBox">ComboBox</a> or <a href="../commands/GuiControls.htm#ListBox">ListBox</a> control. If none is selected, zero is returned. If text is entered into a ComboBox, the first item with matching text is used. If there is no matching item, the result is zero even if there is text in the control. For a <a href="../commands/GuiControls.htm#ListBoxMulti">multi-select ListBox</a>, the result is an array of numbers (which is empty if no items are selected).</p>
<p><em>NewValue</em> is the position of a single item/tab to select, or zero to clear the current selection (this is valid even for Tab controls). To select multiple items, call <a href="#Choose">GuiCtrl.Choose</a> repeatedly.</p>
<p>To get or set the selected item given its text instead of its position, use <a href="#Text">GuiCtrl.Text</a>.</p>

<h3>ActiveX</h3>
<p><em>RetrievedValue</em> is the ActiveX object of the <a href="../commands/GuiControls.htm#ActiveX">ActiveX</a> control. 例如, if the control was created with the text <em>Shell.Explorer</em>, this is a <a href="https://msdn.microsoft.com/library/aa752043">WebBrowser</a> object. The same <a href="../commands/ComObject.htm">wrapper object</a> is returned each time.</p>
</div>

<div class="methodShort" id="Text">
<h2>Text</h2>
<p>Retrieves or sets the text/caption of the control.</p>
<pre class="Syntax">RetrievedText := GuiCtrl.Text</pre>
<pre class="Syntax">GuiCtrl.Text := NewText</pre>
<p>Note: If the control has no visible caption text and no (single) text value, this property corresponds to the control's hidden caption text (like <a href="../commands/ControlGetText.htm">ControlGetText</a>/<a href="../commands/ControlSetText.htm">ControlSetText</a>).</p>
<p><strong>Caption/display text</strong>: The <em>Text</em> property retrieves or sets the caption/display text of the following control types: <a href="../commands/GuiControls.htm#Button">Button</a>, <a href="../commands/GuiControls.htm#Checkbox">Checkbox</a>, <a href="../commands/GuiControls.htm#Edit">Edit</a>, <a href="../commands/GuiControls.htm#GroupBox">GroupBox</a>, <a href="../commands/GuiControls.htm#Link">Link</a>, <a href="../commands/GuiControls.htm#Radio">Radio</a>, <a href="../commands/GuiControls.htm#Text">Text</a>. Since the control will not expand automatically, use <code>GuiCtrl.<a href="#Move">Move</a>("w300")</code> or similar if the control needs to be widened.</p>

<p><strong><a href="../commands/GuiControls.htm#DateTime">DateTime</a></strong>: The <em>Text</em> property retrieves the formatted text displayed by the control. Assigning a formatted date/time string to the control is not supported. To change the date/time being displayed, assign <a href="#Value">GuiCtrl.Value</a> a date-time stamp in <a href="../commands/FileSetTime.htm#YYYYMMDD">YYYYMMDDHH24MISS</a> format.</p>

<p><strong><a href="../commands/GuiControls.htm#Edit">Edit</a></strong>: As with other controls, the text is retrieved or set as-is; no end-of-line translation is performed. To retrieve or set the text of a multi-line Edit control while also translating between <code>`r`n</code> and <code>`n</code>, use <a href="#Value">GuiCtrl.Value</a>.</p>

<p><strong><a href="../commands/GuiControls.htm#StatusBar">StatusBar</a></strong>: The <em>Text</em> property retrieves or sets the text of the first part only (use <a href="../commands/GuiControls.htm#SB_SetText">SB.SetText</a> for greater flexibility).</p>

<p><strong>List item text</strong>: The <em>Text</em> property retrieves or sets the currently selected item/tab for the following control types: <a href="../commands/GuiControls.htm#Tab">Tab</a>, <a href="../commands/GuiControls.htm#DropDownList">DropDownList</a>, <a href="../commands/GuiControls.htm#ComboBox">ComboBox</a>, <a href="../commands/GuiControls.htm#ListBox">ListBox</a>.</p>
<p><em>NewText</em> should be the full text (case insensitive) of the item/tab to select.</p>
<p>For a ComboBox, if there is no selected item, the text in the control's edit field is retrieved instead. For other controls, <em>RetrievedText</em> is empty/blank. Similarly, if <em>NewText</em> is empty/blank, the current item/tab will be deselected.</p>
<p>For a <a href="../commands/GuiControls.htm#ListBoxMulti">multi-select ListBox</a>, <em>RetrievedText</em> is an array. <em>NewText</em> cannot be an array, but if multiple items match, they are all selected. To select multiple items with different text, call <a href="#Choose">GuiCtrl.Choose</a> repeatedly.</p>
<p>To select an item by its position number instead of its text, use <a href="#Value">GuiCtrl.Value</a>.</p>

</div>

<div class="methodShort" id="SetFont">
<h2>SetFont</h2>
<p>Sets the font typeface, size, style, and/or color for the control.</p>
<p>Note: Omit both parameters to set the font to the GUI's current font, as set by <a href="Gui.htm#SetFont">Gui.SetFont</a>. Otherwise, any font attributes which are not specified will be copied from the control's previous font. Text color is changed only if specified in <em>Options</em>.</p>
<pre class="Syntax">GuiCtrl.<span class="func">SetFont</span>(<span class="optional">Options, FontName</span>)</pre>
<p>For details about both parameters, 请参阅 <a href="Gui.htm#SetFont">Gui.SetFont</a>.</p>
</div>

<div class="methodShort" id="Enabled">
<h2>Enabled</h2>
<p>Retrieves the current interaction state of the control, or enables or disables (grays out) it.</p>
<pre class="Syntax">RetrievedState := GuiCtrl.Enabled</pre>
<pre class="Syntax">GuiCtrl.Enabled := NewState</pre>
<p>For Tab controls, this will also enable or disable all of the tab's sub-controls. However, any sub-control explicitly disabled via <code>GuiCtrl.Enabled := false</code> will remember that setting and thus remain disabled even after its Tab control is re-enabled.</p>
</div>

<div class="methodShort" id="Visible">
<h2>Visible</h2>
<p>Retrieves the current visibility state of the control, or shows or hides it.</p>
<pre class="Syntax">RetrievedState := GuiCtrl.Visible</pre>
<pre class="Syntax">GuiCtrl.Visible := NewState</pre>
<p>For Tab controls, this will also show or hide all of the tab's sub-controls. If you additionally want to prevent a control's shortcut key (underlined letter) from working, disable the control via <code>GuiCtrl.Enabled := false</code>.</p>
</div>

<div class="methodShort" id="Focused">
<h2>Focused</h2>
<p>Retrieves the current focus state of the control.</p>
<pre class="Syntax">RetrievedState := GuiCtrl.Focused</pre>
<p>Note: To be effective, the window generally must not be minimized or hidden.</p>
</div>

<div class="methodShort" id="Pos">
<h2>Pos</h2>
<p>Retrieves the position and size of the control.</p>
<pre class="Syntax">PosSizeObj := GuiCtrl.Pos</pre>
<p>The position is relative to the GUI window's client area, which is the area not including title bar, menu bar, and borders. The information is stored in an <a href="../Objects.htm">object</a>. 例如:</p>
<pre>value := MyEdit.Pos
MsgBox "The X coordinate is " value.x ". The Y coordinate is " value.y ". The width is " value.w ". The height is " value.h "."
</pre>
</div>
</body>
</html>